﻿using ReflectionStudio.Core.Events;
using System;
using System.Data;
using System.Windows;
using System.Windows.Data;
using System.ComponentModel;
namespace WPFExcelReport
{
    public partial class TSWS02
    { 
        public TSWS02()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            MV = new VWASTAMM();
            this.DataContext = MV;
            InitializeComponent();   
        } 
        public override void vwMaster_CurrentChanged(object sender, EventArgs e)
        {
            if (dwMain == null)
            {
            } 
            if (dwMaster == null)
            {
                KEY = "";
                TXTISIND = "";
                ART = "";
                VAR = "";
            }
            else
            {
                ART = TMV.WAART;
                VAR = TMV.WAVAR;
                KEY = "F"+TMV.WAART + TMV.WAVAR;
                TXTISIND = ("00000000      " + TMV.WAART + TMV.WAVAR).PadRight(60);
            }
            dwWS = dwMaster;
        }
        
        public override void LOADALL()
        {
            if (TBMain == null)
                return;
            dwData = TBMain.NewRow();
            dwData["WAMANDANT"] = app.Mandant;
            dwData["WAART"] ="";
            dwData["WAFKZ"] ="J";
            SResult = TMV.QWS_1(dwData); 
            MergeData(SResult,false);
        }  
        public override void OnLIEFNRChg(string ls)
        {
            filter = "WALIEFNR LIKE '" + ls + "%'";
            cvMaster.CustomFilter = filter;
            base.OnLIEFNRChg(ls);
        }
        public override void ManageCommand(object sender, RoutedEventArgs e)
        {
            if (!IsManage)
            {
                VICC_WFEVENTS.SVWF.WS02(RUNID);
            }
            else
            {
                LOADALL();
            }
            base.ManageCommand(sender, e);
        }
        public override void OnEXAUFChg(string vlaue)
        {
            TBMain.Clear();
            if (EXAUF.Length < 22)
                return;
            dwData = TBMain.NewRow();
            dwData["WAMANDANT"] = app.Mandant;
            dwData["WAART"] = EXAUF.Substring(1,20);
            dwData["WAFKZ"] = "J";
            SResult = TMV.QWS_1(dwData);
            MergeData(SResult, true);
            base.OnEXAUFChg(vlaue);
        } 
        public override void OnDESSChg()
        {
            TBMain.Clear();
            if (PARTIE.Length < 22)
                return;
            dwData = TBMain.NewRow();
            dwData["WAMANDANT"] = app.Mandant;
            dwData["WAART"] = PARTIE.Trim();
            dwData["WAFKZ"] = "J";
            SResult = TMV.QWSDESS(dwData);
            MergeData(SResult, true);
            base.OnDESSChg();
        }

    }
}
